package com.hn.service.impl;

import com.hn.mapper.DeptMapper;
import com.hn.mapper.EmpMapper;
import com.hn.pojo.Dept;
import com.hn.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Autowired
    private EmpMapper empMapper;
    @Override
    public List<Dept> selectAll() {
        return deptMapper.selectAll();
    }

    @Override
    public Integer deleteById(Integer id) {
        Integer integer = deptMapper.deleteById(id);
        empMapper.deleteByDeptId(id);
        return integer;
    }

    @Override
    public Integer addByName(Dept dept) {
        return deptMapper.addByName(dept);
    }

    @Override
    public List<Dept> selectById(Integer id) {
        return deptMapper.selectById(id);
    }

    @Override
    public Integer updateName(Dept dept) {
        return deptMapper.updateName(dept);
    }
}
